<template>
<view class="flex_c">
  <nav-bar title="我的投递" />
  <view class="flex1" style="overflow: hidden;">
    <scroll-view
      v-if="totalHeight"
      scroll-y
      :style="{ height: `calc(100vh - ${totalHeight}px -  env(safe-area-inset-bottom) - 30rpx) ` }"
      :lower-threshold="130"
      @scrolltolower="onMore"
      refresher-enabled
      :refresher-triggered="triggered"
      @refresherrefresh="onRefresh"
      >
      <view v-show="isShow" @click="onLink('/pages/center/infomation/person')" class="banner pt-19 pl-20">
        <image class="close" @click.stop="isShow = false" src="https://zsjl.oss-cn-beijing.aliyuncs.com/test/xcx/close2_icon.png"></image>
        <image class="banner_img" src="https://zsjl.oss-cn-beijing.aliyuncs.com/test/xcx/ip_banner.png"></image>
      </view>
      <view class="pl-20 pr-20 pt-20">
        <navigator :url="`/pages/ipElite/recruitDetail?id=${item.id}`" hover-class="none" class="mb-15" v-for="item in list"
          :key="item.id">
          <recruit-card :item="item">
            <template v-slot:count="{ item }">
              <!-- <view class="flex_a_c count">
                <image class="address_icon" src="https://zsjl.oss-cn-beijing.aliyuncs.com/test/xcx/address_icon.png"></image>
                {{ item.provinceName }}<template v-if="item.cityName">·{{item.cityName}}</template>
                <template v-if="item.status === 2">
                  <image class="icon" src="https://zsjl.oss-cn-beijing.aliyuncs.com/test/xcx/see_count1_icon.png"></image>
                  <text>{{ item.deliveryNum }}</text>
                </template>
              </view> -->
            </template>
          </recruit-card>
        </navigator>
      </view>
      <van-empty v-if="total === 0" class="pt-60" image="https://zsjl.oss-cn-beijing.aliyuncs.com/test/xcx/empty.png"
        description="暂无投递" />
      <view v-if="total && total === list.length" class="all_tip">到底了</view>
    </scroll-view>
  </view>
</view>
</template>
<script setup>
import recruitCard from "@/components/ipElite/recruit-card"
import { getMyDelivery } from "@/api/center"
import { ref, reactive, toRefs, onBeforeMount, getCurrentInstance } from 'vue'
const { appContext: { config: { globalProperties: { totalHeight } } } } = getCurrentInstance();

let data = reactive({
	form: {
    pageSize: 40,
		pageCode: 1,
	},
	list: [],
	total: '',
  triggered: false
})
onBeforeMount(() => {
  fnGet()
})
let fnGet = async () => {
  const { code, data: { total, rows } } = await getMyDelivery(form)
  if (code === 200) {
    data.list = data.list.concat(rows)
    data.total = total
    data.triggered = false
  }
}
let onLoad = e => {
  if (data.total > data.list.length) {
    ++form.pageCode
    fnGet()
  }
}
let onRefresh = () => {
  form.pageCode = 1
  data.list = []
  data.triggered = true
  fnGet()
}
let { form, list, total, triggered } = toRefs(data)
</script>
<style lang="scss">
::v-deep .card  .count {
  justify-content: flex-start;
}
</style>
